﻿using System.Collections.Generic;

namespace CustomerContactSystem.Core.Infrastructure.Domain {
    public abstract class ValidatableObject {
        private readonly List<BusinessRule> _brokenRules = new List<BusinessRule>();

        protected abstract void Validate();

        public virtual IEnumerable<BusinessRule> GetBrokenRules() {
            _brokenRules.Clear();
            Validate();
            return _brokenRules;
        }

        protected void AddBrokenRule(BusinessRule businessRule) {
            _brokenRules.Add(businessRule);
        }
    }
}